// <copyright file="MessengerService.cs" company="Clever Software">
// Copyright (c) 2013, 2014 All Right Reserved, http://www.cleversoftware.by
//
// This source is subject to the Microsoft Permissive License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Clever Software</author>
// <email>info@cleversoftware.by</email>
// <date>2014-02-04</date> 
// <summary>CleverCMS source code</summary>

namespace CleverCMS.Core.Services
{
    using System;
    using System.Configuration;
    using System.Net.Mail;

	public class MessengerService : IMessengerService
	{
		#region IMessengerService Members
        /// <summary>
        /// Email sending function
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="isBodyHtml"></param>
        /// <returns></returns>
		public bool Send(string from, string to, string subject, string body, bool isBodyHtml)
		{
			var isSuccess = false;
			
			try
			{
                var msg = new MailMessage(ConfigurationManager.AppSettings["Email"] , to, subject, body)
                {
                    IsBodyHtml = isBodyHtml
                };
			    var smtp = new SmtpClient();
				smtp.SendAsync(msg, null);
				isSuccess = true;
			}
			catch (Exception ex)
			{
				//TODO: Log exception
			}
		
			return isSuccess;
		}

		#endregion
	}
}